﻿using CommunityToolkit.Mvvm.ComponentModel;
using MeasureAbstract.Base;
using Microsoft.VisualBasic;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Reflection;
using System.Collections.Concurrent;
using NPOI.HPSF;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using static Org.BouncyCastle.Bcpg.Attr.ImageAttrib;
using NPOI.SS.Formula.Functions;
using MathNet.Numerics;
using MeasureAbstract.IReport;

namespace MeasureAbstract.IFarfieldMeasure
{
    [INotifyPropertyChanged]
    public abstract partial class IFarfieldMeasure : IMeasureBase
    {
        public abstract string MeasureName { get; }
        public abstract string Description { get; }


        private ObservableCollection<IDeviceBase> _DeviceList;
        public ObservableCollection<IDeviceBase> DeviceList
        {
            get { return _DeviceList; }
            set { SetProperty(ref _DeviceList, value); }
        }



        public abstract Task MeasureInitialize(object obj);
        public abstract void MeasurePause();
        public abstract void MeasureContinue();

        public abstract void MeasureReset();
        public abstract Task MeasureStart(object Type);
        public abstract void MeasureStop();
        public abstract void SaveData(object obj);



        //测量过程相关





        //安全相关过程处理





        //测量信息相关






        //不确定度相关




        [ObservableProperty]
        private string antennaName = "";

        [ObservableProperty]
        private string antennaModel = "";

        [ObservableProperty]
        private string polarizationDirection = "水平极化";

        [ObservableProperty]
        private string note = "";


        [ObservableProperty]
        private bool realTimeSave = true;

        [ObservableProperty]
        private string fileName = DateTime.Now.ToString("yyyyMMddHHmm");

        [ObservableProperty]
        private string fileType = "txt";

        [ObservableProperty]
        private string dataFilePath = "";

        public ManualResetEvent ManualResetEvent = new ManualResetEvent(true);
        public bool StopFlag = false;
        public bool InitBreak = false;

        public MeasureData MeasureData = new MeasureData();
        public RealTimeCache RealTimeCache = new RealTimeCache();

        //可能用到的外部数据
        public dynamic SystemConfig { get; set; }
        public dynamic ExternalData { get; set; }
        public abstract double Process { get; set; }


        //数据记录
        /// <summary>
        /// 数据记录，频率响应时用
        /// </summary>
        public Dictionary<double, ObservableCollection<DataItem>> DataDictPosition_FrequencyCollection;

        /// <summary>
        /// 数据记录
        /// </summary>
        public Dictionary<double, ObservableCollection<DataItem>> DataDictFrequency_PositionCollection;

        [ObservableProperty]
        private ObservableCollection<double> frequencyList;

        /// <summary>
        /// 生成报告
        /// </summary>
        [ObservableProperty]
        private IReport.IReport report;


    }


    [INotifyPropertyChanged]
    public abstract partial class IFarfieldMeasure_GB40602_1 : IMeasureBase
    {
        public abstract string MeasureName { get; }
        public abstract string Description { get; }
        public abstract ObservableCollection<IDeviceBase> DeviceList { get; set; }
        public abstract double Process { get; set; }

        public abstract void MeasureContinue();
        public abstract Task MeasureInitialize(object obj);
        public abstract void MeasurePause();
        public abstract void MeasureReset();
        public abstract Task MeasureStart(object Type);
        public abstract void MeasureStop();
        public abstract void SaveData(object obj);
    }

    //public class DataItem
    //{
    //    /// <summary>
    //    /// 位置
    //    /// </summary>
    //    [DisplayName("位置")]
    //    public double Position { get; set; } = 0d;

    //    /// <summary>
    //    /// 频率
    //    /// </summary>
    //    /// 
    //    [DisplayName("频率")]
    //    public double Frequency { get; set; } = 0d;

    //    /// <summary>
    //    /// 幅度值
    //    /// </summary>
    //    [DisplayName("对数幅度")]
    //    public double LogarithmicAmplitude { get; set; } = 0;

    //    /// <summary>
    //    /// 相位值
    //    /// </summary>
    //    [DisplayName("相位")]
    //    public double Phase { get; set; } = 0;

    //    [DisplayName("线性幅度")]
    //    public double LinearAmplitude { get; set; } = 0;

    //    [DisplayName("实部")]
    //    public double RealPart { get; set; } = 0;

    //    [DisplayName("虚部")]
    //    public double ImaginaryPart { get; set; } = 0;

    //    [DisplayName("驻波比")]
    //    public double StandingWaveRatio { get; set; } = 0;

    //    [DisplayName("群延时")]
    //    public double GroupDelay { get; set; } = 0;

    //}

    
    

}